package com.diseaseInformation

class EngineinformationController {
    telemedicine.MyformatToHtmlService myformatToHtmlService
    
    def getdata = { // Use for Tooltip Resault
        def model
        if(params['type']=="management"){
            model = Management.read(params.id)
        }else if(params['type']=="disease"){
            model = Disease.read(params.id)
        }else if(params['type']=="problem"){
            model = Problem.read(params.id)
        }else if(params['type']=="terminology"){
            model = Terminology.read(params.id)
        }else if(params['type']=="laboratory"){
            model = Laboratory.read(params.id)
        }else if(params['type']=="caseScenario"){
            model = CaseScenario.read(params.id)
        }
        model.data = myformatToHtmlService.toHtmlTagWebboard(model.data)
        render model as grails.converters.JSON
    }
    
    
    def tooltip={
        render ((Terminology.findByName(params.value)!=null)?Terminology.findByName(params.value).data:"")
    }
    
    def autotag = {
		def st = myformatToHtmlService.autotag(params)
                render st //String
    }
   
    def findtag = {
		def st = myformatToHtmlService.findtag(params)
                render st as grails.converters.JSON
    }
    
    def preview = {
        //System.out.println(params)
        def st = myformatToHtmlService.toHtmlTagWebboard(params.value)
        render st //String
    }
}
